package com.ss.android.article.base.app;

import android.os.Build;
import android.os.HandlerThread;
import android.text.TextUtils;
import com.bytedance.article.common.nativecrash.NativeCrashInit;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.b.ThreadPlus;
import com.ss.android.crash.log.CrashUtils;
import com.ss.android.crash.log.b;
import com.ss.android.crash.log.d;
import com.ss.android.crash.log.h;
import com.ss.android.crash.log.i;
import com.ss.android.crash.log.j;

final class c extends ThreadPlus {
    private final AppData a;

    c(AppData arg1, String arg2) {
        super(arg2);
        this.a = arg1;
    }

    public final void run() {
        int v2;
        int v0 = 0;
        int v3 = 2;
        try {
            if((a.a(this.a) == 1 || a.a(this.a) == v3) && (a.b(this.a) != v3 && a.b(this.a) != 1) || (a.a(this.a) != 1 && a.a(this.a) != v3) ) {
                if(a.a(this.a) == 1 || a.a(this.a) == v3) {
                    v2 = 1;
                }else if(a.b(this.a) != v3 && a.b(this.a) != 1) {
                    v2 = 0;
                }else {
                    v2 = v0;
                    v0 = 1;
                }
            } else {
                v0 = 1;
                v2 = v0;
                v0 = 1;
            }

            if(v2 != 0 || v0 != 0) {
                if(a.a(this.a) == 1) {
                    com.ss.android.crash.log.c.a();
                }

                j v1 = j.a(a.c(this.a).getApplicationContext());
                i.a(v1.a, new com.ss.android.crash.log.j.j$a());
                if(v2 != 0) {
                    com.ss.android.crash.log.c v2_1 = h.a(v1.a).a;
                    if(!v2_1.e) {
                        v2_1.b = new HandlerThread("anr_monitor");
                        v2_1.b.start();
                        v2_1.c = new b(v2_1, v2_1.b.getLooper());
                        if(Build.VERSION.SDK_INT < 21) {
                            v2_1.a = new com.ss.android.crash.log.a(v2_1, "/data/anr/");
                            v2_1.a.startWatching();
                        }
                        else {
                            v2_1.d = new d(v2_1);
                            v2_1.d.start();
                        }

                        v2_1.e = true;
                    }
                }

                String v2_2 = CrashUtils.a(v1.a);
                if(v0 == 0) {
                }else if(TextUtils.isEmpty(((CharSequence)v2_2))) {
                }else {
                    NativeCrashInit.a(v1.a, "ss_native_android_crash_logs", "ss_native_crash-", v2_2);
                }
            }

            a.d(this.a);
        }
        catch(Throwable v0_1) {
            Logger.e("AppData", "", v0_1);
        }
    }
}

